public class text {
    public static void main(String[] args) {
//        int flag=new AdminDaoImpl().login("mk","123456");
//        if (flag==1){
//            System.out.println("登录成功！");
//        }else if (flag==2){
//            System.out.println("密码错误");
//            login();
//        } else if (flag == 3) {
//            System.out.println("用户名错误");
//            login();
//        }
//
//    }
//
////    private static void login() {
//        CameraDaoImpl caDao = new CameraDaoImpl();
//       int i=caDao.delCaById(10);
//        System.out.println(i);

//        CameraDaoImpl caDao = new CameraDaoImpl();

//         Cameras ca1 = new Cameras(10, "xc", "佳能", 4566.00, "已出售");
//         System.out.println("请输入要修改的id号：");
//        Scanner sc = new Scanner(System.in);
//        int id = sc.nextInt();
//        caDao.updateCa(ca1,id);
//        Cameras ca2=caDao.getCaById(1);
//        System.out.println(ca2);

        List<Cameras> cameraAll = getCameraAll();
        Iterator it = cameraAll.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }

       /* for (Cameras camera:cameraAll) {
            System.out.println(camera);
        }*/


    }

    public static List<Cameras> getCameraAll() throws SQLException, ClassNotFoundException {
        List<Cameras> list = new ArrayList<Cameras>();
        Connection con = ConnectionManager.getCon();
        String sql = "select * from camera";
        PreparedStatement psmt = con.prepareStatement(sql);
        ResultSet rs = psmt.executeQuery();
        while (rs.next()) {
            Cameras cs = new Cameras();
            //这里就是给属性都重新赋值，赋的值是查出来的那些信息
            cs.setId(rs.getInt(1));
            cs.setModel(rs.getString(2));
            cs.setBrand(rs.getString(3));
            cs.setPrice(rs.getDouble(4));
            cs.setStatus(rs.getString(5));
            list.add(cs);
        }
        rs.close();
        psmt.close();
        con.close();
        return list;

